Telegram Group & Telegram Channel
Что выведет этот код на Python?


x = [1, 2, 3]
y = x
x += [4]

print(x)
print(y)


🔢 Варианты ответа:

A)

[1, 2, 3]


B)

[1, 2, 3, 4]


C)

[1, 2, 3, 4]


D)

[1, 2, 3]


Правильный ответ: B

💡 Почему?
-
x = [1, 2, 3] и y = x — ссылка на один и тот же список.
-
x += [4] модифицирует список на месте.
- Поэтому
y тоже видит изменение.
🧠 Подвох — в
+=, который работает не как x = x + [...].



tg-me.com/python_job_interview/1072
Create:
Last Update:

Что выведет этот код на Python?


x = [1, 2, 3]
y = x
x += [4]

print(x)
print(y)


🔢 Варианты ответа:

A)

[1, 2, 3]


B)

[1, 2, 3, 4]


C)

[1, 2, 3, 4]


D)

[1, 2, 3]


Правильный ответ: B

💡 Почему?
-
x = [1, 2, 3] и y = x — ссылка на один и тот же список.
-
x += [4] модифицирует список на месте.
- Поэтому
y тоже видит изменение.
🧠 Подвох — в
+=, который работает не как x = x + [...].

BY Python вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_job_interview/1072

View MORE
Open in Telegram


Python вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.

If riding a bucking bronco is your idea of fun, you’re going to love what the stock market has in store. Consider this past week’s ride a preview.The week’s action didn’t look like much, if you didn’t know better. The Dow Jones Industrial Average rose 213.12 points or 0.6%, while the S&P 500 advanced 0.5%, and the Nasdaq Composite ended little changed.

Python вопросы с собеседований from pl


Telegram Python вопросы с собеседований
FROM USA